<template>
  <div>
    <div class="div">
      <img src="./imgs/bo-mei.jpg" alt="" />
      <p @click="fn" :style="{ background: dogColor }">{{ name }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "MyDog",
  components: {},
  props: {
    url: {
      type: String,
      required: true,
    },
    name: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      dogColor: "",
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    fn() {
      this.dogColor = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      this.$emit('like',this.name)
    },
  },
};
</script>

<style scoped>
.div {
  width: 280px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.div img {
  width: 100%;
  height: 200px;
}
</style>
